home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / csim / source.lha / source / C++SIM / gnu_thread.h < prev    next >
C/C++ Source or Header  |  1993-06-14  |  1KB  |  56 lines

  1. /*
  2.  * Copyright (C) 1993
  3.  *
  4.  * Department of Computing Science,
  5.  * The University,
  6.  * Newcastle upon Tyne,
  7.  * UK.
  8.  */
  9.  
  10. #ifndef GNU_THREAD_H_
  11. #define GNU_THREAD_H_
  12.  
  13. #ifndef COMMON_H_
  14. #include "common.h"
  15. #endif
  16.  
  17. #ifndef THREAD_H_
  18. #include "thread.h"
  19. #endif
  20.  
  21.  
  22. #define MINPRIO 2
  23.  
  24.  
  25. class GNU_Thread : public Thread
  26. {
  27. public:
  28.     virtual void Suspend ();                // Suspend an active thread
  29.     virtual void Resume ();                 // Resume a suspended thread
  30.  
  31.     virtual void Body () = 0;               // Body of "active" object (defined in the deriving class)
  32.     virtual long Current_Thread () const;   // Returns current thread id
  33.  
  34.     // Initialize must be called exactly once at the start of the program
  35.     static void Initialize ();
  36.  
  37. protected:
  38.     static const int MaxPriority; // Maximum priority of a thread
  39.     static long base_key;
  40.  
  41.     GNU_Thread (int priority = MaxPriority); // Create thread with given (or maximum) priority
  42.     virtual ~GNU_Thread ();
  43.  
  44. private:
  45.     static void Execute (int, char**, GNU_Thread*); // This routine calls the 'main' object code
  46.     static boolean DoWait;
  47.     static boolean SuspendMain;
  48.     static int count;
  49.  
  50.     long thread_key;
  51.     struct sem* to_wait;
  52.     struct pcb* my_block;
  53. };
  54.  
  55. #endif
  56.